package DesignPatern.A05_建造者模式.QXB.A03高级模式.Product;

import java.util.ArrayList;

/**
 * @Author: Du
 * @Date: 2021/7/21 10:26
 */
public abstract class CarModel
{
    private ArrayList<String> sequence = new ArrayList<>();
    
    public abstract void start();
    
    public abstract void stop();
    
    public abstract void alarm();
    
    public abstract void engineBoom();
    
    public void run()
    {
        for (int i = 0; i < this.sequence.size(); i++)
        {
            String actionName = this.sequence.get(i);
            if (actionName.equalsIgnoreCase("start"))
            {
                this.start();
            } else if (actionName.equalsIgnoreCase("stop"))
            {
                this.stop();
            } else if (actionName.equalsIgnoreCase("alarm"))
            {
                this.alarm();
            } else if (actionName.equalsIgnoreCase("engine boom"))
            {
                this.engineBoom();
            }
        }
    }
    
    public void setSequence(ArrayList<String> sequence)
    {
        this.sequence = sequence;
    }
}
